package com.cmcc.fj12580.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.LinearLayout;

import com.cmcc.fj12580.R;

public class TowLevelListLayout extends LinearLayout {

	public ExpandableListView elv;
	public LinearLayout refreshlayout;
	private Button netrefresh;

	public TowLevelListLayout(Context context) {
		super(context);
		layoutInit(context);
	}

	public TowLevelListLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		layoutInit(context);
	}

	private void layoutInit(Context context) {
		LayoutInflater lytInflater = LayoutInflater.from(context);
		LinearLayout view = (LinearLayout) lytInflater.inflate(R.layout.preferential_list, this);

		elv = (ExpandableListView) view.findViewById(R.id.expandableListView);
		refreshlayout = (LinearLayout) view.findViewById(R.id.netrefresh_linear);
		netrefresh = (Button) view.findViewById(R.id.netrefresh2);
	}

	public void setListener(Context context) {
		elv.setOnChildClickListener((OnChildClickListener) context);
		elv.setOnGroupClickListener((OnGroupClickListener) context);
		netrefresh.setOnClickListener((OnClickListener) context);
	}

	public void setExpandableListAdapter(BaseExpandableListAdapter viewAdapter) {
		elv.setAdapter(viewAdapter);
	}
}
